-- @owner: cr13
-- @date: 2024-10-15
-- @testpoint: 触发器函数入参,支持传递以f/d结尾的浮点数作为参数

--step1:打开参数float_suffix_acceptance expect:成功
set float_suffix_acceptance=on;
show float_suffix_acceptance;

--step2:建普通表 expect:成功
drop table if exists t_tbl_0012_01;
drop table if exists t_tbl_0012_02;
CREATE TABLE t_tbl_0012_01(id1 INT, id2 INT, id3 INT);
CREATE TABLE t_tbl_0012_02(id1 INT, id2 INT, id3 INT);

--step3:创建函数 expect:成功
drop function if exists f_fun_0012;
CREATE OR REPLACE FUNCTION f_fun_0012() RETURNS TRIGGER AS
$$
DECLARE
input_value FLOAT;
BEGIN
input_value := TG_ARGV[o]::FLOAT;
INSERT INTO t_tbl_0012_02 VALUES(NEW.id1, NEW.id2, NEW.id3, input_value);
RETURN NEW;
END
$$ LANGUAGE PLPGSQL;
/

--step4:建触发器 expect:成功
CREATE TRIGGER t_tri_0012 
BEFORE INSERT ON t_tbl_0012_01
FOR EACH ROW  
EXECUTE PROcEDURE f_fun_0012(2.5f);
/


DROP TRIGGER t_tri_0012 ON t_tbl_0012_01;


CREATE TRIGGER t_tri_0012 BEFORE INSERT ON t_tbl_0012_01 FOR EACH ROW EXECUTE PROCEDURE f_fun_0012(2.5d);
/

--step5:清理环境 expect:成功
DROP TRIGGER if exists t_tri_0012 ON t_tbl_0012_01;
drop function if exists f_fun_0012;
drop table if exists t_tbl_0012_01;
drop table if exists t_tbl_0012_02;


